<?php

if (!defined('TOBBIVM'))
	header('location:/template/notrepassing.php');
/**
 * This file is part of TobbiVMShop.
 *
 * TobbiVMShop is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * TobbiVMShop is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with TobbiVMShop.  If not, see <http://www.gnu.org/licenses/>.
 */
/**
 * create payment edit page
 * used from payment.page.php
 * get: payment.edit.tpl.php
 *
 * @version    $Id$
 * @package    TobbiVM-Shop
 * @copyright  Copyright (C) 2012
 * @author     Norbert Gebert
 * @license    GPL3
 */
db::getInstance()->where('plugin_id', $refValidate->cleanslash($_GET['id']));
$result = db::getInstance()->getOne('plugin');

if (db::getInstance()->count <= 0)
{
	message::setErrorRow(_('Databaseerror! - Contact Admin!'), true);
}
else
{
	$refPage->assign('page_title', _('Plugin settings'));

	$refPage->assign('id', _('xPlugin-Id'));
	$refPage->assign('idx',
		'<input type="text" name="idxx" id="idxx" disabled="disabled" ' .
		'size="8" value="' . $result['plugin_id'] . '" />');

	$refPage->assign('name', _('Name'));
	$refPage->assign('namex',
		'<input type="text" name="namex" id="namex" disabled="disabled" ' .
		'size="35" value="' . $result['plugin_name'] . '" />');

	$refPage->assign('typ', _('xPlugintyp'));

	switch ($result['plugin_typ'])
	{
		case 'H':
			$typy = _('Head');
			break;
		case 'C':
			$typy = _('Content');
			break;
		default:
			$typy = _('Unknow!');
			break;
	}
	$refPage->assign('typx',
		'<input type="text" name="typx" id="typx" disabled="disabled" ' .
		'size="35" value="' . $typy . '" />');
	$refPage->assign('typxHelp', help('plugintyp', $page));

	$refPage->assign('active', _('Activ'));
	$activey = '<input type="checkbox" name="activex" id="activex" value="activex" ';

	if ($result['plugin_active'] === 0)
	{
		$activey .= '/>';
	}
	else
	{
		$activey .= 'checked />';
	}
	$refPage->assign('activex', $activey);
	$refPage->assign('activexHelp', help('pluginactive', $page));

	if ($result['plugin_typ'] === 'C')
	{
		$refPage->assign('code', _('Code'));
		$refPage->assign('codex',
			'<input type="text" name="codex" id="codex" disabled="disabled" ' .
			'size="35" value="{' . $result['plugin_code'] . '}" />');
		$refPage->assign('codexHelp', help('plugincode', $page));

		// Config-Data
		$refPage->assign('configx', xplugin::getValues($result['plugin_id']));

		$refPage->assign('Form_End',
			'<input type = "hidden" name = "idx" value = "' . $result['plugin_id'] . '">' .
			'<input type = "hidden" name = "configx" value = "configx">' .
			'</fieldset></form>');
	}
	else
	{
		$refPage->assign('config');
		$refPage->assign('configx');
		$refPage->assign('code');
		$refPage->assign('codex');
		$refPage->assign('codexHelp');
		$refPage->assign('Form_End',
			'<input type = "hidden" name = "idx" value = "' . $result['plugin_id'] . '">' .
			'</fieldset></form>');
	}

	$refPage->assign('Form_Start',
		'<form class = "niceform fieldset" action = "' .
		'index2.php?page=' . $page . '&sub=' . $subpage .
		'" method = "post"><fieldset>');

	$refPage->assign('btn_save',
		'<input type = "submit" name = "submit" id = "save" value = "' .
		_('Save') . '" />');
	$refPage->assign('btn_abort',
		'<input type = "submit" name = "submit" id = "abort" value = "' .
		_('Cancel') . '" />');
	//$refPage->assign('xPluginPageHelp', help($result['payment_file'], $page, TRUE));
	$refPage->addtpl('content', '/' . $page . '/' . $subpage . '.editor.tpl.php');
}
?>